function Ryqkfx(){
	this.InitOrg();
	this.GetStatisData();
}

Ryqkfx.prototype.InitOrg = function() {
	var comboboxm=$("#orgid").ligerComboBox({
		valueField : 'orgid',
		textField : 'orgname',
		selectBoxWidth : 250,
		selectBoxHeight:250,
		treeLeafOnly:false,
		valueFieldID:"hid",
		tree: {url : '../common/get_org_list?orgtype=0',
			checkbox: false, 
			nodeWidth:150,
			ajaxType: 'get', 
			idFieldName: 'orgid',
			textFieldName:"orgname",
			idField:"orgid",
        	parentIDField:"orgparentid"
		},
		onSelected : function(orgid, orgname) {// id为空值，name为选择的值
			$("#hidszdw").val(orgid);
			//vPyResultTj.searchlist();
		},
		width : 250
	});
	return comboboxm;
}

Ryqkfx.prototype.searchlist=function(){
    $.ajax({
        type:"GET",
        url:"../getstatisdatabyorg",
        data:{orgid:$("#hidszdw").val()},
        beforeSend:function(XHR){

        },
        success:function(data){
            //alert(data);
            data=eval('('+data+')');
            if(data.result>0){
                if(data.items){
                    if(data.items.ageMap){
                        var ageobject=data.items.ageMap[0];
                        var agedata=[];
                        agedata.push(ageobject.count30);
                        agedata.push(ageobject.count35);
                        agedata.push(ageobject.count40);
                        agedata.push(ageobject.count45);
                        agedata.push(ageobject.count50);
                        agedata.push(ageobject.count55);
                        agedata.push(ageobject.count60);
                        InitChats(agedata);
                    }


                    if(data.items.dyMap){
                        var dyobject=data.items.dyMap[0];
                        var dydata=[];
                        dydata.push(dyobject.count30);
                        dydata.push(dyobject.count35);
                        dydata.push(dyobject.count40);
                        dydata.push(dyobject.count45);
                        dydata.push(dyobject.count50);
                        dydata.push(dyobject.count55);
                        dydata.push(dyobject.count60);
                        InitChatsDy(dydata);
                    }

                    if(data.items.xlMap){
                        var xlobject=data.items.xlMap[0];
                        var xldata=[];
                        xldata.push(xlobject.czxl);
                        xldata.push(xlobject.gzxl);
                        xldata.push(xlobject.zzxl);
                        xldata.push(xlobject.zgxl);
                        xldata.push(xlobject.dzxl);
                        xldata.push(xlobject.bkxl);
                        xldata.push(xlobject.ssxl);
                        xldata.push(xlobject.bsxl);
                        InitChatsXl(xldata);
                    }



                }

            }
            else{

            }
        },
        complete:function(XHR){

        },
        error:function(){

        }
    });
}


Ryqkfx.prototype.GetStatisData=function(){
	$.ajax({
		type:"GET",
		url:"../getstatisdata",
		//data:{vtdpid:vtdpid},
		beforeSend:function(XHR){
			
		},
		success:function(data){
			//alert(data);
			data=eval('('+data+')');
			if(data.result>0){
				if(data.items){
					if(data.items.ageMap){
						var ageobject=data.items.ageMap[0];
						var agedata=[];
						agedata.push(ageobject.count30);
						agedata.push(ageobject.count35);
						agedata.push(ageobject.count40);
						agedata.push(ageobject.count45);
						agedata.push(ageobject.count50);
						agedata.push(ageobject.count55);
						agedata.push(ageobject.count60);
						InitChats(agedata);
					}
					
					
					if(data.items.dyMap){
						var dyobject=data.items.dyMap[0];
						var dydata=[];
						dydata.push(dyobject.count30);
						dydata.push(dyobject.count35);
						dydata.push(dyobject.count40);
						dydata.push(dyobject.count45);
						dydata.push(dyobject.count50);
						dydata.push(dyobject.count55);
						dydata.push(dyobject.count60);
						InitChatsDy(dydata);
					}
					
					if(data.items.xlMap){
						var xlobject=data.items.xlMap[0];
						var xldata=[];
						xldata.push(xlobject.czxl);
						xldata.push(xlobject.gzxl);
						xldata.push(xlobject.zzxl);
						xldata.push(xlobject.zgxl);
						xldata.push(xlobject.dzxl);
						xldata.push(xlobject.bkxl);
						xldata.push(xlobject.ssxl);
						xldata.push(xlobject.bsxl);
						InitChatsXl(xldata);
					}
					
					
					
				}
				
			}
			else{
				
			}
		},
		complete:function(XHR){
			
		},
		error:function(){
			
		}
	});
}

var vRyqkfx=null;
$(function(){
	vRyqkfx=new Ryqkfx();
})



function InitChats(agedata){
	$("#Chart").width($(window).width()-30);
	$("#Chart").height($(window).height()/2-80);
	var myChart = echarts.init(document.getElementById('Chart'));
	option = {
//		    title: {
//		        text: '年龄',
//		        left:'center',
//		        textStyle: {
//		              fontWeight: "normal",
//		              color: "#aadeff", 
//		              fontSize: 14
//		        }
//		    },
		    tooltip: {
		        trigger: 'axis',
		        axisPointer: {
		           // type: 'shadow'
		        },
		        backgroundColor:'#3187c2'
		        //,formatter:'{b0} {c}人'
		        	,formatter: function(params) {
	                    var result = '';
	                    params.forEach(function (item) {
	                    	//alert(JSON.stringify(item))
	                    	var agename=item.name;
	                    	if(Number(item.name)==30){
	                    		agename='30岁以下';
	                    	}
	                    	else{
	                    		agename=(Number(item.name)-5)+'-'+item.name+"岁";
	                    	}
	                        result += "  "+item.marker +agename+"："+ item.value +"人";
	                    });
	                    return result;
	                },
	                textStyle: {
			              fontWeight: "normal",
			              color: "#aadeff", 
			              fontSize: 8
			        }
		    },
		    grid:{
                x:40,
                y:10,
                x2:20,
                y2:20,
                borderWidth:1
            },
		    toolbox: {
		        show: true,
		        feature: {
		            //saveAsImage: {}
		        }
		    },
		    xAxis:  {
		        type: 'category',
		        boundaryGap: true,
		        data: [ '30', '35','40','45','50','55','60'],
		        axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#aadeff'
                    }
                },
                axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    yAxis: {
		        type: 'value',
		        axisLabel: {
		            formatter: '{value}',
		            color: '#61a6e7'
		        },
		        axisPointer: {
		            snap: true
		        },
		        splitLine: {           // 分隔线
			        show: true,        // 默认显示，属性show控制显示与否
			        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
			            color: ['#4170a8'],
			            width: 1,
			            type: 'solid'
			        }
			    },
			    splitArea: {           // 分隔区域
			        show: true,       // 默认不显示，属性show控制显示与否
			        areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
			            color: ['#305d94','none']
			        }
			    },
			    axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    


		   /* visualMap: {
		        show: false,
		        dimension: 0,
		        pieces: [{
		            lte: 6,
		            color: '#3986b0'
		        }]
		    },*/
		    
		    series: [
		        {
		            name:'年',
		            type:'line',
		            smooth: true,
		            symbolSize: 8,//拐点大小
		            itemStyle : {  
                        normal : {  
                        	 color:'#00FF00',  
                             lineStyle:{  
                                 color:'#825c8b'  
                             }    
                        }  
                    }, 
		            data: agedata
		        }
		    ]
		};
	 myChart.setOption(option);
	 myChart.on('click', function (param){
		 ShowEdit(1,param.name);
	 })
}

function InitChatsDy(dydata){
	$("#ChartDy").width($(window).width()/2-20);
	$("#ChartDy").height($(window).height()/2-55);
	var myChart = echarts.init(document.getElementById('ChartDy'));
	option = {
//		    title: {
//		        text: '党员',
//		        left:'center',
//		        textStyle: {
//		              fontWeight: "normal",
//		              color: "#aadeff", 
//		              fontSize: 14
//		        }
//		    },
		    tooltip: {
		        trigger: 'axis',
		        axisPointer: {
		           // type: 'shadow'
		        },
		        backgroundColor:'#3187c2'
		        //,formatter:'{b0} {c}人'
		        	,formatter: function(params) {
	                    var result = '';
	                    params.forEach(function (item) {
                            var agename=item.name;
                            if(Number(item.name)==30){
                                agename='30岁以下';
                            }
                            else{
                                agename=(Number(item.name)-5)+'-'+item.name+"岁";
                            }
                            result += "  "+item.marker +agename+"："+ item.value +"人";
	                    });
	                    return result;
	                },
	                textStyle: {
			              fontWeight: "normal",
			              color: "#aadeff", 
			              fontSize: 8
			        }
		    },
		    grid:{
                x:40,
                y:10,
                x2:20,
                y2:35,
                borderWidth:1
            },
		    toolbox: {
		        show: true,
		        feature: {
		            //saveAsImage: {}
		        }
		    },
		    xAxis:  {
		        type: 'category',
		        boundaryGap: true,
		        data: [ '30', '35','40','45','50','55','60'],
		        axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#aadeff'
                    }
                },
                axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    yAxis: {
		        type: 'value',
		        axisLabel: {
		            formatter: '{value}',
		            color: '#61a6e7'
		        },
		        axisPointer: {
		            snap: true
		        },
		        splitLine: {           // 分隔线
			        show: true,        // 默认显示，属性show控制显示与否
			        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
			            color: ['#2180c5'],
			            width: 1,
			            type: 'solid'
			        }
			    },
			    splitArea: {           // 分隔区域
			        show: true,       // 默认不显示，属性show控制显示与否
			        areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
			            color: ['#25619f','none']
			        }
			    },
			    axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    


		   /* visualMap: {
		        show: false,
		        dimension: 0,
		        pieces: [{
		            lte: 6,
		            color: '#3986b0'
		        }]
		    },*/
		    
		    series: [
		        {
		            name:'年',
		            type:'line',
		            smooth: true,
		            itemStyle : {  
                        normal : {  
                        	 color:'#00FF00',  
                             lineStyle:{  
                                 color:'#88d7db'  
                             }    
                        }  
                    }, 
		            data: dydata
		        }
		    ]
		};
	 myChart.setOption(option);
	 myChart.on('click', function (param){
		 ShowEdit(2,param.name);
	 })
}


function InitChatsXl(xldata){
	$("#ChartXl").width($(window).width()/2-20);
	$("#ChartXl").height(($(window).height()/2-55));
	var myChart = echarts.init(document.getElementById('ChartXl'));
	option = {
//		    title: {
//		        text: '学历',
//		        left:'center',
//		        textStyle: {
//		              fontWeight: "normal",
//		              color: "#aadeff", 
//		              fontSize: 14
//		        }
//		    },
		    tooltip: {
		        trigger: 'axis',
		        axisPointer: {
		           // type: 'shadow'
		        },
		        backgroundColor:'#3187c2'
		        //,formatter:'{b0} {c}人'
		        	,formatter: function(params) {
	                    var result = '';
	                    params.forEach(function (item) {
	                    	//alert(JSON.stringify(item))
	                        result += "   "+item.marker +item.name+"：     "+ item.value +"人";
	                    });
	                    return result;
	                },
	                textStyle: {
			              fontWeight: "normal",
			              color: "#aadeff", 
			              fontSize: 8
			        }
		    },
		    grid:{
                x:30,
                y:10,
                x2:20,
                y2:35,
               
                borderWidth:1
            },
		    toolbox: {
		        show: true,
		        feature: {
		            //saveAsImage: {}
		        }
		    },
		    xAxis:  {
		        type: 'category',
		        boundaryGap: true,
		        data: [ '初中','高中','中专','职高','专科','本科','硕士','博士'],
		        axisLabel: {
                    show: true,
                    textStyle: {
                        color: '#aadeff'
                    },
                    interval:0
                    //,rotate:270
                },
                axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    yAxis: {
		        type: 'value',
		        show: true,
		        axisLabel: {
		            formatter: '{value}',
		            color: '#61a6e7'
		        },
		        axisPointer: {
		            snap: true
		        },
		        splitLine: {           // 分隔线
			        show: true,        // 默认显示，属性show控制显示与否
			        lineStyle: {       // 属性lineStyle（详见lineStyle）控制线条样式
			            color: ['#2180c5'],
			            width: 1,
			            type: 'solid'
			        }
			    },
			    splitArea: {           // 分隔区域
			        show: true,       // 默认不显示，属性show控制显示与否
			        areaStyle: {       // 属性areaStyle（详见areaStyle）控制区域样式
			            color: ['#25619f','none']
			        }
			    },
			    axisTick:{
			    	show:false
			    },
			    axisLine:{
			    	show:false
			    }
		    },
		    

		    series: [
		        {
		            name:'年',
		            type:'bar',
		            smooth: true,
		            itemStyle : {  
                        normal : {  
                        	 color: new echarts.graphic.LinearGradient(
                                     0, 0, 0, 1,
                                   [
                                       {offset: 0, color: '#3899ff'},   // {offset: 0, color: '#2FDE80'},   
                                       {offset: 1, color: '#71effd'}//  {offset: 1, color: '#2FDECA'}
                                   ])
  
                        }  
                    }, 
                    barWidth : 30,
		            data: xldata
		        }
		    ]
		};
	 myChart.setOption(option);
	 myChart.on('click', function (param){
		
		 ShowEdit(3,param.name);
	 })
}


function ShowEdit(flag,xname){
	if(flag==3){
		xname=encodeURI(encodeURI(xname));
	}
	
	top.mylayui.open({
        type: 2,
        title: '用户详情',
        shadeClose: true,
        shade: 0.5,
        area: ['870px', '550px'],
        content: 'zhfx/ryqkfx_user_detail?flag='+flag+"&xname="+xname+"&szdw="
      }); 
}
